#include <iostream>
#include <vector>
#include <algorithm>

using std::vector;
using std::cin;
using std::cout;

template <typename iter>
void merge (iter first_begin, iter first_end, iter second_begin, iter second_end, iter buffer) {
    while (first_begin != first_end && second_begin != second_end) {
        if (*first_begin < *second_begin) {
            *buffer = *first_begin;
            ++buffer;
            ++first_begin;
        }
        else {
            *buffer = *second_begin;
            ++buffer;
            ++second_begin;
        }
    }
    while (first_begin != first_end) {
        *buffer = *first_begin;
        ++buffer;
        ++first_begin;
    }
    while (second_begin != second_end) {
        *buffer = *second_begin;
        ++buffer;
        ++second_begin;
    }
}
template <typename iter>
void sort (iter begin, iter end, iter buffer) {
    if(end - begin == 1)
        return;
    sort(begin, begin + (end - begin) / 2, buffer);
    sort(begin + (end - begin) / 2, end, buffer);
    merge(begin, begin + (end - begin) / 2, begin + (end - begin), end, buffer);
    merge(buffer, buffer + end - begin, end, end, begin);
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int m;
    cin >> m;
    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    vector <int> res(n+m);
    merge(a.begin(), a.end(), b.begin(), b.end(), res.begin());
    for (int i = 0; i < res.size(); ++i) {
        cout << res[i] << ' ';
    }
    return 0;
}